/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.Adriano Teste.
 */
package br.com.digitalpoint.utils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import javax.swing.JOptionPane;

/**
 *
 * @author DSA
 */
public class FabricaConexao
{

    /*
     * Conexão MySQL
     */
    //private static String URL = "jdbc:mysql://localhost:3306/BDDigitalPoint";
    //private static String DRIVER = "com.mysql.jdbc.Driver";
    //private static String USUARIO = "digitalpoint";
    //private static String SENHA = "online";

    /*
     * Conexão Microsoft SQL Server 2005
     */
    private static String URL = "jdbc:sqlserver://localhost:1433;databaseName=BDDigitalPoint";
    private static String DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
    private static String USUARIO = "digitalpoint";
    private static String SENHA = "online";
    static Connection con;

    public static Connection abreConexao(){
        try {
            Class.forName(DRIVER);
            con = DriverManager.getConnection(URL,USUARIO,SENHA);
            return con;
        }catch(ClassNotFoundException e) {
            JOptionPane.showMessageDialog(null, "Classe não encontrada!");
            e.printStackTrace();
        }catch(SQLException e) {
            JOptionPane.showMessageDialog(null, "Não foi possivel conectar ao Banco!");
            e.printStackTrace();
        }
        return con;
    }

     public static void fechaConexao(){
     try {
        con.close();
    } catch(SQLException erro) {
        JOptionPane.showMessageDialog(null, "Não foi possivel fechar a conexão!");
        erro.printStackTrace();
     }
}

}